define(['app'], function(app) {
	'use strict';

	//实例化方法
	var factory = function(Http) {
		//编辑
		function get_data_addEdit(result) {
			if(false) {
				result = '{"success": true,"msg": "","result": {"id": "001"},"session": "7311da98bd0f18eb15a96bcb263f4153"}';
				return JSON.parse(result);
			} else {
				return result;
			}
		}
		//数据
		function get_rightlist(result) {
			if(false) {//真实接口自己返回一个数组，不是right:格式
				result = '{"success":true,"msg":"","result":[{"right_id":"001","right_name":"退货","right_type":"A类权限"},{"right_id":"002","right_name":"退货","right_type":"A类权限"},{"right_id":"003","right_name":"退货","right_type":"A类权限"},{"right_id":"004","right_name":"退货","right_type":"A类权限"},{"right_id":"005","right_name":"退货","right_type":"A类权限"},{"right_id":"006","right_name":"退货","right_type":"A类权限"},{"right_id":"011","right_name":"退款","right_type":"B类权限"},{"right_id":"012","right_name":"退款","right_type":"B类权限"},{"right_id":"013","right_name":"退款","right_type":"B类权限"},{"right_id":"014","right_name":"退款","right_type":"B类权限"},{"right_id":"015","right_name":"退款","right_type":"B类权限"},{"right_id":"016","right_name":"退款","right_type":"B类权限"}],"session":"7311da98bd0f18eb15a96bcb263f4153"}';
				return JSON.parse(result);
			} else {
				return result;
			}
		}

		//返回信息
		return {
			get_rights: function(callback) {
				Http.post({
					method: 'member.assistente.rightlist',
				}, function(result) {
					if(callback)
						callback(get_rightlist(result).result);
				}, function(e) {

				}, function() {

				})
			},
			//编辑店员角色 增加
			get_add_eadit: function(id,name,right,callback) {
				var params = new Object();
				params.id = id;
				params.name = name;
				params.right = right;
				params = JSON.stringify(params)
				Http.post({
					method: 'member.assistente.partedit',
					updateParams:params
				}, function(result) {
					if(callback)
						callback(result);
				}, function(e) {

				}, function() {

				})
			},
			//根据店员角色得到权限内容
			partdetail: function(role_id,callback){
				Http.post({
					method: 'member.assistente.partdetail',
					role_id:role_id
				}, function(result) {
					if(callback)
						callback(result);
				}, function(e) {

				}, function() {

				})
			}
		};
	}

	factory.$inject = ['Http'];
	return app.registerService("Employeemanager_rights_add", factory);
});